package com.ruoyi.web.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.HaManufacturer;
import com.ruoyi.system.service.IHaManufacturerService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 生产厂家Controller
 * 
 * @author 鲍小伟
 * @date 2025-11-21
 */
@RestController
@RequestMapping("/system/manufacturer")
public class HaManufacturerController extends BaseController
{
    @Autowired
    private IHaManufacturerService haManufacturerService;

    /**
     * 查询生产厂家列表
     */
    @PreAuthorize("@ss.hasPermi('system:manufacturer:list')")
    @GetMapping("/list")
    public TableDataInfo list(HaManufacturer haManufacturer)
    {
        startPage();
        List<HaManufacturer> list = haManufacturerService.selectHaManufacturerList(haManufacturer);
        return getDataTable(list);
    }

    /**
     * 导出生产厂家列表
     */
    @PreAuthorize("@ss.hasPermi('system:manufacturer:export')")
    @Log(title = "生产厂家", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HaManufacturer haManufacturer)
    {
        List<HaManufacturer> list = haManufacturerService.selectHaManufacturerList(haManufacturer);
        ExcelUtil<HaManufacturer> util = new ExcelUtil<HaManufacturer>(HaManufacturer.class);
        util.exportExcel(response, list, "生产厂家数据");
    }

    /**
     * 获取生产厂家详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:manufacturer:query')")
    @GetMapping(value = "/{mid}")
    public AjaxResult getInfo(@PathVariable("mid") Integer mid)
    {
        return success(haManufacturerService.selectHaManufacturerByMid(mid));
    }

    /**
     * 新增生产厂家
     */
    @PreAuthorize("@ss.hasPermi('system:manufacturer:add')")
    @Log(title = "生产厂家", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HaManufacturer haManufacturer)
    {
        return toAjax(haManufacturerService.insertHaManufacturer(haManufacturer));
    }

    /**
     * 修改生产厂家
     */
    @PreAuthorize("@ss.hasPermi('system:manufacturer:edit')")
    @Log(title = "生产厂家", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HaManufacturer haManufacturer)
    {
        return toAjax(haManufacturerService.updateHaManufacturer(haManufacturer));
    }

    /**
     * 删除生产厂家
     */
    @PreAuthorize("@ss.hasPermi('system:manufacturer:remove')")
    @Log(title = "生产厂家", businessType = BusinessType.DELETE)
	@DeleteMapping("/{mids}")
    public AjaxResult remove(@PathVariable Integer[] mids)
    {
        return toAjax(haManufacturerService.deleteHaManufacturerByMids(mids));
    }
}
